def IEEE754toFloat(n):
    s = '0b' + n[0]
    e = '0b' + n[1:9]
    m = n[9:]

    S = int(s, base=2)
    E = int(e, base=2)

    M = 1.0
    for i in range(len(m)):
        k = int(m[i])
        if k == 1:
            M += 2**(-i-1)

    return (-1)**S * M * 2**(E-127)
        
def floatToIEEE754(n):
    if float(n) == 0.0:
        return '0'*32
    S = '0'
    if n<0:
        S = '1'
        n *= -1

    inter = int(n)
    frac = n%1

    interB = bin(inter)[2:]

    fracB = ''
    while frac!=0:
        fracB += str((frac*2)//1)[0]
        frac = (frac*2)%1
    
    if interB != '0':
        E = len(interB)-1 + 127
        E = bin(E)[2:]
        M = interB[1:] + fracB
    
    elif interB == '0':
        E = 127 - (fracB.find('1')+1)
        E = bin(E)[2:]
        M = fracB[fracB.find('1')+1 :]
        
    
    E = '0'*(8-len(E)) + E

    if len(M)<23:
        M += '0'*(23-len(M))
    elif len(M)>23:
        M = M[:22] + '1'
        
    return S + E + M

if __name__ == '__main__':
    """
        
    teste = '''00111111100000000000000000000000 01000000000000000000000000000000
    01000000010000000000000000000000 01000000100000000000000000000000
    01000000101000000000000000000000 01000000110000000000000000000000
    01000000111000000000000000000000 01000001000000000000000000000000
    01000001000100000000000000000000 01000001001000000000000000000000
    01000001001100000000000000000000 01000001010000000000000000000000
    01000001010100000000000000000000 01000001011000000000000000000000
    01000001011100000000000000000000 01000001100000000000000000000000'''

    teste=teste.split()

    for i in teste:
        print(IEEE754toFloat(i))
    """

    teste = '''10000000000000001000000000000001000111111110000000000000000000000
    10000000000000010000000000000001101000000001000000000000000000000
    10000000000000011000000000000010001000000011000000000000000000000
    10000000000000100000000000000010101000000100100000000000000000000
    00000000000000101000000000000011001000000101100000000000000000000'''

    teste = teste.split()

    for i in teste:
        print(IEEE754toFloat(i[-32:]))


